﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ScriptEditor.Commands
{
    class Command_Wait : Command
    {
        public float duration
        {
            get
            {
                float result = float.TryParse(Value1, out result) ? result : 0.5f;
                return result;
            }
            set
            {
                Value1 = value.ToString();
            }
        }
        public string[] waitingIds
        {
            get
            {
                return Value2.Split(new char[] { '|' });
            }
            set
            {
                if (value != null && value.Length != 0)
                {
                    Value2 = value[0];
                    for (int i = 1; i < value.Length; i++)
                    {
                        Value2 += "|" + value[i].ToString();
                    }
                }
                else
                {
                    Value2 = "";
                }
            }
        }
        public Command_Wait()
        {
            CommandType = COMMANDTYPE.Wait;
            duration = 0.5f;
            waitingIds = new string[0];
            Wait = true;
        }
        public Command_Wait(float Duration, string[] WaitingIds = null)
        {
            CommandType = COMMANDTYPE.Wait;
            duration = Duration;
            waitingIds = WaitingIds;
            Wait = true;
        }
        public override string ToString()
        {
            return CommandType.ToString() + ":\n" + "等待:" + duration.ToString();
        }
    }
}
